﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Management
{
    class DbHelper
    {
        private static string User = "server=DESKTOP-94MMT2C;database=Blogs;uid=sa;pwd=123456";
        public static DataTable GetDataTable(string cmdSting)
        {
            SqlConnection sqlConnection = new SqlConnection(User);
            sqlConnection.Open();
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(cmdSting,sqlConnection);

            DataTable dataTable = new DataTable();
            sqlDataAdapter.Fill(dataTable);
            return dataTable;
        }

        public static int AddOrUpdateOrDelete(string cmdSting)
        {
            SqlConnection sqlConnection = new SqlConnection(User);
            sqlConnection.Open();

            SqlCommand sqlCommand = new SqlCommand(cmdSting,sqlConnection);

            return sqlCommand.ExecuteNonQuery();
        }
    }
}
